home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Lose Your Marbles! 1.0 / source / ls code ƒ / ls shift.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  3.7 KB  |  168 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        ls shift.c
  4.  
  5. Purpose:    This module handles shifting/rotating the board.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program in a file named "GNU General Public License".
  19. If not, write to the Free Software Foundation, 675 Mass Ave,
  20. Cambridge, MA 02139, USA.
  21.  
  22. \**********************************************************************/
  23.  
  24. #include "ls shift.h"
  25. #include "program globals.h"
  26.  
  27. void ShiftLeftDispatch(ExtendedWindowDataHandle theData)
  28. {
  29.     short            tempValue;
  30.     short            theRow, theColumn;
  31.     short            moveIter;
  32.     
  33.     for (theRow=0; theRow<gNumRows; theRow++)
  34.     {
  35.         tempValue=Board[theRow][0];
  36.         
  37.         for (theColumn=0; theColumn<gNumColumns-1; theColumn++)
  38.         {
  39.             Board[theRow][theColumn]=Board[theRow][theColumn+1];
  40.         }
  41.         
  42.         Board[theRow][gNumColumns-1]=tempValue;
  43.     }
  44.     
  45.     for (moveIter=0; moveIter<gNumMoves; moveIter++)
  46.     {
  47.         gMoves[moveIter].h--;
  48.         if (gMoves[moveIter].h<0)
  49.             gMoves[moveIter].h=gNumRows-1;
  50.     }
  51.     
  52.     gCurrentColumn--;
  53.     if (gCurrentColumn<0)
  54.         gCurrentColumn=gNumColumns-1;
  55.     
  56.     (**theData).offscreenNeedsUpdate=TRUE;
  57.     UpdateTheWindow(theData);
  58. }
  59.  
  60. void ShiftRightDispatch(ExtendedWindowDataHandle theData)
  61. {
  62.     short            tempValue;
  63.     short            theRow, theColumn;
  64.     short            moveIter;
  65.     
  66.     for (theRow=0; theRow<gNumRows; theRow++)
  67.     {
  68.         tempValue=Board[theRow][gNumColumns-1];
  69.         
  70.         for (theColumn=gNumColumns-1; theColumn>0; theColumn--)
  71.         {
  72.             Board[theRow][theColumn]=Board[theRow][theColumn-1];
  73.         }
  74.         
  75.         Board[theRow][0]=tempValue;
  76.     }
  77.     
  78.     for (moveIter=0; moveIter<gNumMoves; moveIter++)
  79.     {
  80.         gMoves[moveIter].h++;
  81.         if (gMoves[moveIter].h==gNumRows)
  82.             gMoves[moveIter].h=0;
  83.     }
  84.     
  85.     gCurrentColumn++;
  86.     if (gCurrentColumn==gNumColumns)
  87.         gCurrentColumn=0;
  88.     
  89.     (**theData).offscreenNeedsUpdate=TRUE;
  90.     UpdateTheWindow(theData);
  91. }
  92.  
  93. void ShiftUpDispatch(ExtendedWindowDataHandle theData)
  94. {
  95.     short            tempValue;
  96.     short            theRow, theColumn;
  97.     short            moveIter;
  98.     
  99.     for (theColumn=0; theColumn<gNumColumns; theColumn++)
  100.     {
  101.         tempValue=Board[0][theColumn];
  102.         
  103.         for (theRow=0; theRow<gNumRows-1; theRow++)
  104.         {
  105.             Board[theRow][theColumn]=Board[theRow+1][theColumn];
  106.         }
  107.         
  108.         Board[gNumColumns-1][theColumn]=tempValue;
  109.     }
  110.     
  111.     for (moveIter=0; moveIter<gNumMoves; moveIter++)
  112.     {
  113.         gMoves[moveIter].v--;
  114.         if (gMoves[moveIter].v<0)
  115.             gMoves[moveIter].v=gNumColumns-1;
  116.     }
  117.     
  118.     gCurrentRow--;
  119.     if (gCurrentRow<0)
  120.         gCurrentRow=gNumRows-1;
  121.     
  122.     (**theData).offscreenNeedsUpdate=TRUE;
  123.     UpdateTheWindow(theData);
  124. }
  125.  
  126. void ShiftDownDispatch(ExtendedWindowDataHandle theData)
  127. {
  128.     short            tempValue;
  129.     short            theRow, theColumn;
  130.     short            moveIter;
  131.     
  132.     for (theColumn=0; theColumn<gNumColumns; theColumn++)
  133.     {
  134.         tempValue=Board[gNumRows-1][theColumn];
  135.         
  136.         for (theRow=gNumRows-1; theRow>0; theRow--)
  137.         {
  138.             Board[theRow][theColumn]=Board[theRow-1][theColumn];
  139.         }
  140.         
  141.         Board[0][theColumn]=tempValue;
  142.     }
  143.     
  144.     for (moveIter=0; moveIter<gNumMoves; moveIter++)
  145.     {
  146.         gMoves[moveIter].v++;
  147.         if (gMoves[moveIter].v==gNumColumns)
  148.             gMoves[moveIter].v=0;
  149.     }
  150.     
  151.     gCurrentRow++;
  152.     if (gCurrentRow==gNumRows)
  153.         gCurrentRow=0;
  154.     
  155.     (**theData).offscreenNeedsUpdate=TRUE;
  156.     UpdateTheWindow(theData);
  157. }
  158.  
  159. void RotateCCWDispatch(ExtendedWindowDataHandle theData)
  160. {
  161.  
  162. }
  163.  
  164. void RotateCWDispatch(ExtendedWindowDataHandle theData)
  165. {
  166.  
  167. }
  168.